import {
  inviteAwardList
} from '@/api/register'
import {
  app_share_params
} from '@/api/home'
Page({

  data: {
    imgUri: getApp().globalData.imgUri,
    cdn: getApp().globalData.cdn,
    isEnd: false,
    myList:[],
    pageSize:10,
    userId:0,
    addIntegralSum:0,
    share_title:'',
    share_image:'',
  },
  onLoad(){
    let t = this;
    var getgemomemberuser = wx.getStorageSync('getgemomemberuser');
    this.setData({
      userId:getgemomemberuser.userId
    })
    app_share_params({}).then(res => {
      if(res.code == 200){
        var data = JSON.parse(res.data)
        t.setData({
          share_title:data.context,
          share_image:t.data.cdn+data.image,
        });
      }
    });
    t.getMyList();

  },
  getMyList(pageNum = 1) {
    let o = {
      pageNum,
      pageSize: this.data.pageSize,
    }
    inviteAwardList(o).then(res => {
      if(res.code == 200){
        var listData = res.data.listData;
        let list = this.data.myList.concat(listData);
        let isEnd = list.length >= res.data.total;
        this.setData({
          totalIntegral:res.data.totalIntegral,
          myList: list,
          isEnd,
        })

      }
    });
  },
  bindscrolltolower() {
    console.log('bindscrolltolower')
    // this.getShopList(1)
    let { isEnd } = this.data
    if (!isEnd) {
      let pageNum = Math.ceil(this.data.myList.length / this.data.pageSize) + 1
      this.getMyList(pageNum)
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    return {
      title: this.data.share_title,
      path: "/pages/register/register?inviterId="+this.data.userId,
      imageUrl: this.data.share_image,
    }
  }
})